package com.frxuexi.park2304.my

import android.view.View
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.MyApplyBean
import com.frxuexi.park2304.R
import com.frxuexi.park2304.databinding.ItemMyaskBinding

class MyApplyAdapter:BaseQuickAdapter<MyApplyBean,BaseViewHolder>(R.layout.item_myask) {
    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemMyaskBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: MyApplyBean) {
        val binding = DataBindingUtil.getBinding<ItemMyaskBinding>(helper.itemView)!!
        binding.bean=item

        binding.historyStatus.apply {
            when(item.status){
                "空闲","已通过"->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_status)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.green))
                }
                "已占用","巡检中"->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_zhanyong)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.blue))
                }
                "维护中","待审核","未巡检"->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_weihu)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.darkorange))
                }
                "驳回"-> {
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_solid_red)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.redfont))
                }
                "已完成"-> {
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_solid_lightgray)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.darkgray))
                }
            }
        }
    }
}